/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import entities.Client;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;


@ManagedBean(name="registrationHelper")
@RequestScoped
public class RegistrationHelper {
    private String name;
    private String surname;
    private String address;
    private String login;
    private String password;

    public RegistrationHelper() {
    }

    public RegistrationHelper(String name, String surname, String address, String login, String password) {
        this.name = name;
        this.surname = surname;
        this.address = address;
        this.login = login;
        this.password = password;
    }

    public void setAddress(String adress) {
        this.address = adress;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getAddress() {
        return address;
    }

    public String getLogin() {
        return login;
    }

    public String getName() {
        return name;
    }

    public String getPassword() {
        return password;
    }

    public String getSurname() {
        return surname;
    }

    public String create() {
        ClientDAO clientDao = new ClientDAO();
        Client client = new Client(name, surname, address, login, password);
        clientDao.create(client);
        MessageBean mb = new MessageBean("Utworzono pomyślnie konto w naszej księgarni. Teraz możesz dokonać zakupów");
        //SessionManager sm = new SessionManager();
        SessionManager.getInstance().setRequestItem("messageBean", mb);
        return "index";
    }

}
